package com.only4play.productcenter.infrastructure.convert;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-02-27
 */
import com.only4play.productcenter.api.constants.InOutStoreType;

import javax.persistence.AttributeConverter;

public class InOutStoreTypeConverter implements AttributeConverter<InOutStoreType,Integer> {

  @Override
  public Integer convertToDatabaseColumn(InOutStoreType inOutStoreType) {
    return inOutStoreType.getCode();
  }

  @Override
  public InOutStoreType convertToEntityAttribute(Integer code) {
    return InOutStoreType.of(code).orElse(null);
  }
}